<?php


namespace App\Admin\Controllers;

use App\Admin\Forms\Base;
use App\Admin\Forms\Setting;
use App\Admin\Forms\Step\First;
use App\Admin\Forms\Step\Sec;
use App\Http\Controllers\Controller;
use App\Movies;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Collapse;
use Encore\Admin\Widgets\Tab;
use Encore\Admin\Widgets\Table;
use Illuminate\Support\Facades\Request;
use Encore\Admin\Widgets\InfoBox;

class TestController extends Controller
{
    public function show(Content $content)
    {
        $forms = [
            'first' => First::class,
            'setting' => Sec::class,
        ];
        $tab = new Tab();
        $tab->add('Pie', 11);
        $tab->add('Table', new Table());
        $tab->add('Text', 'blablablabla....');
        $infoBox = new InfoBox('收入', 'home', 'blue', '/admin/test/setting', '1024');
        $infoBox2 = new InfoBox('浏览量', 'users', 'blue', '/admin/test/setting', '2323k');
        $infoBox =  $infoBox->render();
        $tab =  $tab->render();
        $collapse = new Collapse();
        $collapse->add('bar',$infoBox);
        $collapse->add('orders',$tab);
        $collapse_html = $collapse->render();
        $base_form = $collapse_html;
        return $content->breadcrumb(
            ['text' => '首页', 'url' => '/admin'],
            ['text' => '用户管理', 'url' => '/admin/users'],
            ['text' => '编辑用户']
        )->header('自定义')
            ->description('这个是自定义页面')
            ->row(function (Row $row)use ($base_form,$infoBox,$infoBox2){
                $row->column(4, function (Column $column)use($infoBox){
                    $column->row($infoBox);
                });
                $row->column(4, $infoBox2);
                $row->column(4, function (Column $column)use($base_form){
                    $column->row($base_form);
                    $column->row(new Setting());
                    $column->row('333');
                });
            });
    }

    public function handle(Request $request)
    {
        // 从$request对象中获取数据来处理...

        // 加入一个成功提示
        admin_success('数据处理成功.');

        // 或者一个错误提示
        admin_success('数据处理成功失败.');

        // 处理完成之后回到原来的表单页面，或者通过返回`redirect()`方法跳转到其它页面
        return back();
    }
}
